home *** CD-ROM | disk | FTP | other *** search
Java Source | 1997-06-19 | 1.2 KB | 50 lines |
- package symantec.itools.awt.util.dialog;
-
- import java.awt.Button;
- import java.awt.Event;
- import java.awt.Frame;
- import java.awt.Dialog;
- import java.awt.Rectangle;
-
- public class DialogBox extends Dialog {
-
- protected Button okButton;
-
- public DialogBox(Frame f) {
- this(f, false);
- }
-
- public DialogBox(Frame f, boolean modal) {
- this(f, "", modal);
- }
-
- public DialogBox(Frame f, String s, boolean modal) {
- super(f, s, modal);
- setResizable(false);
- }
-
- public synchronized void show() {
- Rectangle bounds = getParent().bounds();
- Rectangle abounds = bounds();
-
- move(bounds.x + (bounds.width - abounds.width) / 2,
- bounds.y + (bounds.height - abounds.height) /2);
-
- super.show();
- }
-
- protected void closeDialog() {
- hide();
- dispose();
- }
-
- public boolean handleEvent(Event event) {
- if ((event.target == okButton && event.id == Event.ACTION_EVENT) ||
- (event.target == this && event.id == Event.WINDOW_DESTROY))
- closeDialog();
-
- return super.handleEvent(event);
- }
-
- }
-